<!DOCTYPE html>
<html>
	<head>
		<title>添加心愿</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
		<script src="/js/plugins/jquery/jquery.min.js"></script>
		<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/myInfo.css" />
        <script src="/js/plugins/jrender/jrender.min.js"></script>
        <script src="/js/plugins/form/jquery.form.js"></script>
		<script src="/js/common.js"></script>

		<script>
            $(function () {
                /*获取get请求中带的参数*/
                var params = getParams();
                console.log(params.id);
                if(params.id) {
                    $('#infoForm').attr('action','/wish/'+params.id);
                    $.get("/wish/" + params.id + "/wish", function (data) {
                        console.log(data);
                        $("#infoForm").renderValues(data);
                    });
                }else{
                    $('#infoForm').attr('action','/wish');
				}
                $("#saveBtn").click(function () {
                    $("#infoForm").ajaxSubmit();
                    window.location.href = "/mine/wishPage.html";
                });
            });
		</script>
		
	</head>

	<body>
		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="javascript:window.history.go(-1);">
						<span>取消</span>
					</a>
				</div>
				<div class="col">
					<span>设置心愿单</span>
				</div>
				<div class="col" >
					<a href="#" id="saveBtn" >
						<span>保存</span>
					</a>
				</div>
			</div>
		</div>

		<div class="container info">
			<form id="infoForm" method="post">
					<input type="hidden" name="id" >
					<label>标题</label><input type="text" name="title" class="form-control" render-value="title">
					<label>内容</label><textarea name="content" class="form-control" rows="5" render-value="content"></textarea>
			</form>
		</div>
		
		
		
	</body>
</html>
